﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WHControlLib.CommonHelpers;
using WHControlLib.Controls.Goods;
using WHControlLib.Forms;

namespace WHUIdemo.Forms.PosDemoPageFrm
{
    public delegate void TransparentDiscoutToCurrentGoods(double d);
    public partial class ChangeGoodsDiscountFrm : WHDialogFrm
    {
        Goods InGoods;
       public TransparentDiscoutToCurrentGoods TranDiscontTogoods;

        public ChangeGoodsDiscountFrm(Goods inGoods)
        {
            InGoods = inGoods;
            InitializeComponent();
        }

        private void ChangeGoodsDiscountFrmcs_Load(object sender, EventArgs e)
        {
            if (InGoods != null)
            {
                whLable1.Text = "商品名：" + InGoods.Name + "\n" + "条码：" + InGoods.barcode
                                 + "\n" + "价格：￥" + InGoods.Price.ToString("F2");
            }
        }

        private void ChangeGoodsDiscountFrmcs_Activated(object sender, EventArgs e)
        {
            whTextBox1.Focus();
        }

        private void whNumKeyBoard1_OKButtonCLick(object sender, EventArgs e)
        {
            if (DataCheckHelper.IsNotfufolat(whTextBox1.Text.Trim()))
            {
                double d = Math.Round(Convert.ToDouble(whTextBox1.Text.Trim()), 2);
                if (d<=0)
                {
                   
                    return;
                }
               
               
                TranDiscontTogoods(d);
            }
            this.Close();
        }

        private void whButton1_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{0}{.}{9}{5}");
        }

        private void whButton2_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{0}{.}{9}");
        }

        private void whButton3_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{0}{.}{8}{5}");

        }

        private void whButton4_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{0}{.}{8}");
        }

        private void whButton5_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{0}{.}{6}{5}");
        }

        private void whButton6_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{0}{.}{5}");
        }

        private void whButton7_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{0}{.}{3}{5}");
        }
    }
}
